//-----------------------------------------------------------------------
// <copyright file="ProductBuyService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class ProductBuyService
    {
        #region ProductBuy

        public static void CreateProductBuy(ProductBuy productBuy)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                productBuyDAO.CreateProductBuy(productBuy);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateProductBuyException, ex);
            }
        }        

        public static void UpdateProductBuy(ProductBuy productBuy)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                productBuyDAO.UpdateProductBuy(productBuy);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateProductBuyException, ex);
            }
        }        

        public static void DeleteProductBuy(long productId)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                productBuyDAO.DeleteProductBuy(productId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteProductBuyException, ex);
            }
        }
        
        public static ProductBuy GetProductBuy(long productId)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                return productBuyDAO.GetProductBuy(productId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProductBuyException, ex);
            }
        }                

        public static ProductBuyCollection GetProductBuyList(ProductBuyColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                return productBuyDAO.GetProductBuyList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProductBuyListException, ex);
            }
        }        

        public static ProductBuyCollection GetProductBuyList(ProductBuyColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                return productBuyDAO.GetProductBuyList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProductBuyListException, ex);
            }
        }        

	    public static ProductBuyCollection GetProductBuyListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                return productBuyDAO.GetProductBuyListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProductBuyListException, ex);
            }
        }        

        public static ProductBuyCollection GetProductBuyListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                ProductBuyDAO productBuyDAO = new ProductBuyDAO();
                return productBuyDAO.GetProductBuyListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProductBuyListException, ex);
            }
        }        

        #endregion
    }
}